home *** CD-ROM | disk | FTP | other *** search
- Path: sdrc.com!thor!scjones
- From: larry.jones@sdrc.com (Larry Jones)
- Newsgroups: comp.lang.c
- Subject: Re: Examples of using "volatile"?
- Date: 19 Jan 1996 18:45:55 GMT
- Organization: SDRC Engineering Services
- Distribution: world
- Message-ID: <4doot3$l0u@info1.sdrc.com>
- References: <4djoj2$mr1@post.gsfc.nasa.gov> <4dm91p$bsi@info.uah.edu> <4dnf7f$1sa@fountain.mindlink.net>
- NNTP-Posting-Host: thor.sdrc.com
- Originator: scjones@thor
-
- In article <4dnf7f$1sa@fountain.mindlink.net>, genew@mindlink.bc.ca (Gene Wirchenko) writes:
- > gbacon@oreo (Greg Bacon) wrote:
- >
- > >Basically, like most modifiers, volatile is a hint to the compiler
- > >that the value of i could change at any time, and not to take its
- > >value for granted. Of course, the compiler could ignore you since
- > >it's only a hint, but that wouldn't be a very good compiler :)
- >
- > No, it wouldn't because it would be broken. K&R2, used as a sub
- > for the Standard by those of us without $120 or so to spend on said
- > Standard, says on page 211 (in the indented portion at the bottom):
- > "The purpose of volatile is to force an implementation to
- > suppress optimization that could otherwise occur."
- > Note the word "force".
-
- The problem with using K&R2 as a sub for the Standard is that K&R2 is
- not the Standard -- it sacrifices precision in order to make things
- easier to understand. What Greg said is much closer to what the
- Standard says than what K&R2 says. There are only a couple of
- situations where the Standard imposes specific semantics on volatile
- that a compiler must implement; if the implementor can ensure that those
- situations are handled correctly, the compiler is not broken. Most
- people would expect a high-quality compiler to handle many more system-
- specific situations correctly as well, but that is strictly a quality of
- implementation issue, not a standards conformance issue.
- ----
- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070
- larry.jones@sdrc.com
- There's never enough time to do all the nothing you want. -- Calvin
-